<template>
  <div class="sendback-section">
    <div class="send-content">
      <div class="title"><span><em>子任务</em><b>{{updateServeItem.stName}}</b></span></div>
      <div class="send-form">
        <span>退回意见</span>
        <textarea 
          class="textarea-item"
          placeholder="请输入退回意见"
          v-model="message"
          spellcheck="false"
        ></textarea>
      </div>
    </div>
    <div class="sendbtn">
      <button @click="handleConfirm">确认退回</button>
    </div>
  </div>
</template>

<script>
import moment from 'moment'
import { mapState } from 'vuex'
import {
	subTaskUpdate
} from "../../../request/api"
export default {
  name: "sendback",
  data(){
    return {
      message:""
    }
  },
	computed:{
		...mapState({
			updateServeItem: state=>state.serve.updateServeItem,
		})
	},
  methods:{
    async handleConfirm(){
      if(this.message===""){
        this.$toast({
          message: '请输入反馈意见',
					position: 'bottom',
        })
        return
      }
      const { stId } = this.updateServeItem
      const stBackTime = moment().format("YYYY-MM-DD HH:mm:ss")
      const res = await subTaskUpdate({
        stId,
        stBackTime,
        stBack:this.message,
        stState:3
      })
      if(res.success){
        this.$toast({
					message: '退回成功',
					position: 'bottom',
				})
        // 跳转
        this.$router.replace({
          path:"/serve",
          query:{
            from:"sendback"
          }
        })
        this.$store.commit("serve/clearCurrentSubServeInfo")
        this.message = ""
      }else{
        this.$toast({
					message: '退回失败，请重新操作',
					position: 'bottom',
				})
      }
    }
  }
}
</script>

<style lang="scss" scoped>
@import "../../../assets/style/variable.scss";
.sendback-section{
  height: 100%;
	background: $bg-gray;
  box-sizing: border-box;
  padding: 50px;
  .send-content{
    height: calc(100% - 130px);
    box-sizing: border-box;
    padding: 20px 50px;
    border-radius: 10px;
    background: #fff;
    .title{
      height: 100px;
      @include flexCenter;
      justify-content: flex-start;
      border-bottom: 1px solid rgba(0,0,0,.1);
      margin-bottom: 40px;
      span{
        @include flexCenter;
        em{
          font-size: 20px;
          background: $color-blue;									
          border-radius: 4px;
          padding: 1px 5px;
          margin-right: 5px;
          color: #fff;
        }
        b{
          font-size: 36px;
          font-weight: bold;
        }
      }
    }
    .send-form{
      span{
        display: inline-block;
        font-size: 24px;
        margin-bottom: 20px;
      }
      .textarea-item{
        font-size: 24px;
        padding: 20px;
        width: 100%;
        display: block;
        height: 500px;
        background: #F3F3F3;
        border-radius: 10px;
      }
    }
  }
  .sendbtn{
    margin-top: 40px;
    button{
      height: 90px;
      width: 100%;
      border-radius: 50px;
      background: #F45656;
      color: #fff;
      font-size: 32px;
    }
  }
}
</style>